//api数据返回
export interface requeryRes {
  code?: number; //状态码
  msg?: string; //信息/消息
  other?: string; //其他 扩展字段
  data?: any; //数据
  total?: number; //数据总数，分页用到
}

//表格组件getlist数据返回
export class tableDataQuery {
  page: number; //当前页
  limit: number; //分页
  searchVal: string; //搜索关键词
  type_id?:number;//分类ID
  constructor() {
    this.page = 1;
    this.limit = 20;
    this.searchVal = "";
  }
}

/**
 * 表格组件数据类型
 */
export class tableDataType<T> {
  total: number; //表格总条数
  lists: Array<T>; //表格数据集合  泛型
  loading?: boolean; //加载状态控制
  types: Array<any>; //分类列表
  checkItem: Array<any>; //勾选的数据
  constructor() {
    this.total = 0;
    this.lists = [];
    this.loading = false;
    this.types = [];
    this.checkItem = [];
  }
}

//分类数据类型
export enum typeItemTypeName {
  "goods" = "goods",
  "news" = "news",
  "pages" = "pages",
  "role" = "role",
}

//路由分类数据类型
export enum routerTypeName {
  "list" = "list",//目录
  "menu" = "menu",//菜单
  "button" = "button",//页面按钮
}

//数据类型
export class typeItem {
  id?: number;
  name: string;
  sort: number;
  create_time?: number;
  up_time?: number;
  a_show: string;
  pid: number; //无限级分类id
  other: string;
  img: string;
  type: typeItemTypeName; //分类名称 用来区分是 商品分类 还是 资讯分类
  constructor(type: typeItemTypeName) {
    this.img = "";
    this.type = type;
    this.name = "";
    this.other = "";
    this.sort = 0;
    this.pid = 0;
    this.a_show = "1";
  }
}

//路由
export interface routerItem {
  path: string; //路径
  name: string; //路由名称，生成menu时menu name
  //额外信息，icon为menu中的icon
  meta?: {
    icon: string;
  };
  lang?: string; //多语言配置,如果没有配置，则调用name字段显示
  children?: routerItem[]; //子路由，menu中的子menu 没有时可为空数组
  redirect?: string; //重定向页面，
  component: Component;
}
